package com.ssm.hj.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.hj.search.MemberSearch;
import com.ssm.hj.service.MemberService;
import com.ssm.hj.view.MemberStatisticsView;
import com.ssm.hj.view.MemberView;
import com.ssm.pojo.Member;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class MemberController {
    @Resource
    private MemberService memberService;
    //阿杰 条件查询会员信息
    @RequestMapping("/hj/searchQueryMember")
    public PageInfo<MemberView> searchQueryMember(@RequestBody Page<MemberSearch> page) throws Exception {
        return this.memberService.searchQueryMemberService(page);
    }
    //阿杰 修改状态
    @RequestMapping("/hj/updateState")
    public int updateState(String id,int state) throws Exception {
        return this.memberService.updateState(id,state);
    }
    //阿杰 新增会员
    @RequestMapping("/hj/save")
    public int save(@RequestBody Member member) throws Exception {
        return this.memberService.saveService(member);
    }

    @RequestMapping("/hj/queryMemberByName")
    public List<Member> queryMemberByName(String name){
            return this.memberService.queryMemberByName(name);
    }



    @RequestMapping("/hj/queryMembertj")
    public Map<String, MemberStatisticsView> queryMembertj(String sdate, String enddate){
        return this.memberService.queryMembertj(sdate,enddate);
    }
}
